#!/bin/bash

# Get current Directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

#inlcude config.sh
. $DIR/config.sh

#Get Parrent Directory
Basefolder="$(cd ../; pwd)" 

# WEB SERVICES INSTALLATION
echo "Installing Node & NPM"

    echo "ARMV7L"
    sudo wget https://nodejs.org/dist/v16.13.0/node-v16.13.0-linux-armv7l.tar.xz
    sudo tar -xvf node-v16.13.0-linux-armv7l.tar.xz -C /usr/local
    export PATH=$PATH:/usr/local/node-v16.13.0-linux-armv7l/bin
     cd /
     cd /usr/local/node-v16.13.0-linux-armv7l/
     sudo sleep 20
     #sudo cp -R * /usr/local/
     sudo ln -sf /usr/local/node-v16.13.0-linux-armv7l/ /home/Violet/fpvcast_2046/
     npm config set registry https://registry.npmmirror.com
     curl -sL https://deb.nodesource.com/setup_4.x | sudo bash -
     sudo apt-get install -y npm
     #npm install -g 4.2.0
     sudo npm install pm2@latest -g  
     source ~/.bashrc

  


cd $Basefolder/web
sudo npm install --production
sudo pm2 start process.json --env production
sudo pm2 startup
sudo pm2 save



